{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "import os\n",
    "import numpy as np\n",
    "import pandas as pd\n",
    "import lightgbm as lgb\n",
    "from datetime import datetime\n",
    "from sklearn.metrics import roc_auc_score\n",
    "from sklearn.preprocessing import LabelEncoder\n",
    "from sklearn.model_selection import StratifiedKFold"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "train_path = '../../../contest/train/'\n",
    "stage_path = '../../../contest/A榜/'\n",
    "stage = 'A'\n",
    "end_date = datetime(1993,11,29)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [],
   "source": [
    "df_train = pd.read_csv('../../../contest/train/DZ_TARGET_TRAIN.csv')\n",
    "df_test = pd.read_csv('../../../contest/A榜/DZ_TARGET_TESTA.csv')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [],
   "source": [
    "df_train_user = pd.DataFrame({'CUST_NO':df_train.CUST_NO})\n",
    "df_test_user = pd.DataFrame({'CUST_NO':df_test.cust_no})"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [],
   "source": [
    "def normal_stats(data, group_col, agg_col, fea_prefix, func_trans = ['sum','mean','size', 'max', 'min', 'std' ] ):\n",
    "    grp_data = data.groupby(group_col)[agg_col].agg(\n",
    "        func_trans\n",
    "    )\n",
    "    grp_data.columns = [ f'{fea_prefix}_{group_col}_{agg_col}_{x}' for x in func_trans ]\n",
    "    grp_data = grp_data.reset_index()\n",
    "    return grp_data\n",
    "    \n",
    "\n",
    "def slide_window_stats(data, time_col, group_col,agg_col, window_size, fea_prefix, func_trans = ['sum','mean', 'count', 'max', 'min', 'std' ]):\n",
    "    #func_trans = ['sum','mean', 'size', 'max', 'min', 'std' ]\n",
    "    data['date_gap'] = (end_date - data[time_col]).dt.days + 1\n",
    "    sub_data = data[data['date_gap']<= window_size]\n",
    "    grp_data = sub_data.groupby(group_col)[agg_col].agg(\n",
    "        func_trans\n",
    "    )\n",
    "    grp_data.columns = [ f'{fea_prefix}_{group_col}_{agg_col}_{window_size}_{x}' for x in func_trans ]\n",
    "    grp_data = grp_data.reset_index()\n",
    "    return grp_data\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 活期交易表"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [],
   "source": [
    "tr_train = pd.read_csv(os.path.join(train_path,'DZ_TR_APS.csv'))\n",
    "tr_test = pd.read_csv(os.path.join(stage_path,f'DZ_TR_APS_{stage}.csv'))\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [],
   "source": [
    "def fe_tr_aps(df,merge_df,prefix='aps'):\n",
    "    df = df.rename({'apsdcusno':'CUST_NO'},axis=1)\n",
    "    df['apsdtrdat_d'] = pd.to_datetime(df['apsdtrdat'].astype('str'))\n",
    "    df = df.sort_values(['CUST_NO','apsdtrdat'])\n",
    "    func_trans = ['sum','min','max','mean','std','count']\n",
    "    for win_size in [1,3,5,7,15,30,60]:\n",
    "        df_grp = slide_window_stats(df,'apsdtrdat_d','CUST_NO','apsdtramt',win_size,prefix,func_trans)\n",
    "        merge_df = merge_df.merge(df_grp,on='CUST_NO',how='left')\n",
    "    #30天与60天比\n",
    "  #  merge_df['aps_CUST_NO_apsdtramt_30_60_mean_diff'] = merge_df['aps_CUST_NO_apsdtramt_30_mean'] - merge_df['aps_CUST_NO_apsdtramt_60_mean']\n",
    "  #  merge_df['aps_CUST_NO_apsdtramt_30_60_mean_ratio'] = merge_df['aps_CUST_NO_apsdtramt_30_mean'] / merge_df['aps_CUST_NO_apsdtramt_60_mean']\n",
    "  #  merge_df['aps_CUST_NO_apsdtramt_30_60_min_diff'] = merge_df['aps_CUST_NO_apsdtramt_30_min'] - merge_df['aps_CUST_NO_apsdtramt_60_min']\n",
    "  #  merge_df['aps_CUST_NO_apsdtramt_30_60_min_ratio'] = merge_df['aps_CUST_NO_apsdtramt_30_min'] / merge_df['aps_CUST_NO_apsdtramt_60_min']\n",
    "  #  merge_df['aps_CUST_NO_apsdtramt_30_60_max_diff'] = merge_df['aps_CUST_NO_apsdtramt_30_max'] - merge_df['aps_CUST_NO_apsdtramt_60_max']\n",
    "  #  merge_df['aps_CUST_NO_apsdtramt_30_60_max_ratio'] = merge_df['aps_CUST_NO_apsdtramt_30_max'] / merge_df['aps_CUST_NO_apsdtramt_60_max']\n",
    "\n",
    "\n",
    "    return merge_df\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [],
   "source": [
    "tmp_train = fe_tr_aps(tr_train,df_train_user)\n",
    "tmp_test = fe_tr_aps(tr_test,df_test_user)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [],
   "source": [
    "tmp_train = tmp_train.fillna(0)\n",
    "tmp_test = tmp_test.fillna(0)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>CUST_NO</th>\n",
       "      <th>aps_CUST_NO_apsdtramt_1_sum</th>\n",
       "      <th>aps_CUST_NO_apsdtramt_1_min</th>\n",
       "      <th>aps_CUST_NO_apsdtramt_1_max</th>\n",
       "      <th>aps_CUST_NO_apsdtramt_1_mean</th>\n",
       "      <th>aps_CUST_NO_apsdtramt_1_std</th>\n",
       "      <th>aps_CUST_NO_apsdtramt_1_count</th>\n",
       "      <th>aps_CUST_NO_apsdtramt_3_sum</th>\n",
       "      <th>aps_CUST_NO_apsdtramt_3_min</th>\n",
       "      <th>aps_CUST_NO_apsdtramt_3_max</th>\n",
       "      <th>aps_CUST_NO_apsdtramt_3_mean</th>\n",
       "      <th>aps_CUST_NO_apsdtramt_3_std</th>\n",
       "      <th>aps_CUST_NO_apsdtramt_3_count</th>\n",
       "      <th>aps_CUST_NO_apsdtramt_5_sum</th>\n",
       "      <th>aps_CUST_NO_apsdtramt_5_min</th>\n",
       "      <th>aps_CUST_NO_apsdtramt_5_max</th>\n",
       "      <th>aps_CUST_NO_apsdtramt_5_mean</th>\n",
       "      <th>aps_CUST_NO_apsdtramt_5_std</th>\n",
       "      <th>aps_CUST_NO_apsdtramt_5_count</th>\n",
       "      <th>aps_CUST_NO_apsdtramt_7_sum</th>\n",
       "      <th>aps_CUST_NO_apsdtramt_7_min</th>\n",
       "      <th>aps_CUST_NO_apsdtramt_7_max</th>\n",
       "      <th>aps_CUST_NO_apsdtramt_7_mean</th>\n",
       "      <th>aps_CUST_NO_apsdtramt_7_std</th>\n",
       "      <th>aps_CUST_NO_apsdtramt_7_count</th>\n",
       "      <th>aps_CUST_NO_apsdtramt_15_sum</th>\n",
       "      <th>aps_CUST_NO_apsdtramt_15_min</th>\n",
       "      <th>aps_CUST_NO_apsdtramt_15_max</th>\n",
       "      <th>aps_CUST_NO_apsdtramt_15_mean</th>\n",
       "      <th>aps_CUST_NO_apsdtramt_15_std</th>\n",
       "      <th>aps_CUST_NO_apsdtramt_15_count</th>\n",
       "      <th>aps_CUST_NO_apsdtramt_30_sum</th>\n",
       "      <th>aps_CUST_NO_apsdtramt_30_min</th>\n",
       "      <th>aps_CUST_NO_apsdtramt_30_max</th>\n",
       "      <th>aps_CUST_NO_apsdtramt_30_mean</th>\n",
       "      <th>aps_CUST_NO_apsdtramt_30_std</th>\n",
       "      <th>aps_CUST_NO_apsdtramt_30_count</th>\n",
       "      <th>aps_CUST_NO_apsdtramt_60_sum</th>\n",
       "      <th>aps_CUST_NO_apsdtramt_60_min</th>\n",
       "      <th>aps_CUST_NO_apsdtramt_60_max</th>\n",
       "      <th>aps_CUST_NO_apsdtramt_60_mean</th>\n",
       "      <th>aps_CUST_NO_apsdtramt_60_std</th>\n",
       "      <th>aps_CUST_NO_apsdtramt_60_count</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>235e4e193124d8c55095cf3f0f0d8f35</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.00000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.00000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.00000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.00000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>f1b5ca32a8f7ef5430f5775c00ff3f60</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.00000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.00000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.00000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.00000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>51be6f380b408edeb7779b76e016dcd3</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.00000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.00000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.00000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.00000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.0</td>\n",
       "      <td>-2.556282</td>\n",
       "      <td>-2.556282</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>-1.278141</td>\n",
       "      <td>1.807565</td>\n",
       "      <td>2.0</td>\n",
       "      <td>-2.556282</td>\n",
       "      <td>-2.556282</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>-1.278141</td>\n",
       "      <td>1.807565</td>\n",
       "      <td>2.0</td>\n",
       "      <td>-2.556282</td>\n",
       "      <td>-2.556282</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>-1.278141</td>\n",
       "      <td>1.807565</td>\n",
       "      <td>2.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>ccd7e33ccbe7e9dd4246a2959f666c0a</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.00000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.00000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.00000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.00000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.0</td>\n",
       "      <td>-8.257676</td>\n",
       "      <td>-8.257676</td>\n",
       "      <td>-8.257676</td>\n",
       "      <td>-8.257676</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>1.0</td>\n",
       "      <td>28.234065</td>\n",
       "      <td>-8.257676</td>\n",
       "      <td>36.491741</td>\n",
       "      <td>14.117033</td>\n",
       "      <td>31.642616</td>\n",
       "      <td>2.0</td>\n",
       "      <td>19.451852</td>\n",
       "      <td>-83.254131</td>\n",
       "      <td>83.300844</td>\n",
       "      <td>3.890370</td>\n",
       "      <td>61.790761</td>\n",
       "      <td>5.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>069f48f51bf6be5bcbdc9af52bb20970</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>-123.49848</td>\n",
       "      <td>-21.251208</td>\n",
       "      <td>33.154947</td>\n",
       "      <td>-8.82132</td>\n",
       "      <td>13.228012</td>\n",
       "      <td>14.0</td>\n",
       "      <td>-137.656318</td>\n",
       "      <td>-31.859766</td>\n",
       "      <td>33.154947</td>\n",
       "      <td>-8.09743</td>\n",
       "      <td>16.960602</td>\n",
       "      <td>17.0</td>\n",
       "      <td>-137.656318</td>\n",
       "      <td>-31.859766</td>\n",
       "      <td>33.154947</td>\n",
       "      <td>-8.09743</td>\n",
       "      <td>16.960602</td>\n",
       "      <td>17.0</td>\n",
       "      <td>-174.155486</td>\n",
       "      <td>-42.344915</td>\n",
       "      <td>42.344915</td>\n",
       "      <td>-5.122220</td>\n",
       "      <td>19.844642</td>\n",
       "      <td>34.0</td>\n",
       "      <td>-328.378033</td>\n",
       "      <td>-42.344915</td>\n",
       "      <td>42.344915</td>\n",
       "      <td>-5.130907</td>\n",
       "      <td>17.853094</td>\n",
       "      <td>64.0</td>\n",
       "      <td>-443.849364</td>\n",
       "      <td>-42.344915</td>\n",
       "      <td>42.344915</td>\n",
       "      <td>-4.187258</td>\n",
       "      <td>18.364779</td>\n",
       "      <td>106.0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                            CUST_NO  aps_CUST_NO_apsdtramt_1_sum  \\\n",
       "0  235e4e193124d8c55095cf3f0f0d8f35                          0.0   \n",
       "1  f1b5ca32a8f7ef5430f5775c00ff3f60                          0.0   \n",
       "2  51be6f380b408edeb7779b76e016dcd3                          0.0   \n",
       "3  ccd7e33ccbe7e9dd4246a2959f666c0a                          0.0   \n",
       "4  069f48f51bf6be5bcbdc9af52bb20970                          0.0   \n",
       "\n",
       "   aps_CUST_NO_apsdtramt_1_min  aps_CUST_NO_apsdtramt_1_max  \\\n",
       "0                          0.0                          0.0   \n",
       "1                          0.0                          0.0   \n",
       "2                          0.0                          0.0   \n",
       "3                          0.0                          0.0   \n",
       "4                          0.0                          0.0   \n",
       "\n",
       "   aps_CUST_NO_apsdtramt_1_mean  aps_CUST_NO_apsdtramt_1_std  \\\n",
       "0                           0.0                          0.0   \n",
       "1                           0.0                          0.0   \n",
       "2                           0.0                          0.0   \n",
       "3                           0.0                          0.0   \n",
       "4                           0.0                          0.0   \n",
       "\n",
       "   aps_CUST_NO_apsdtramt_1_count  aps_CUST_NO_apsdtramt_3_sum  \\\n",
       "0                            0.0                      0.00000   \n",
       "1                            0.0                      0.00000   \n",
       "2                            0.0                      0.00000   \n",
       "3                            0.0                      0.00000   \n",
       "4                            0.0                   -123.49848   \n",
       "\n",
       "   aps_CUST_NO_apsdtramt_3_min  aps_CUST_NO_apsdtramt_3_max  \\\n",
       "0                     0.000000                     0.000000   \n",
       "1                     0.000000                     0.000000   \n",
       "2                     0.000000                     0.000000   \n",
       "3                     0.000000                     0.000000   \n",
       "4                   -21.251208                    33.154947   \n",
       "\n",
       "   aps_CUST_NO_apsdtramt_3_mean  aps_CUST_NO_apsdtramt_3_std  \\\n",
       "0                       0.00000                     0.000000   \n",
       "1                       0.00000                     0.000000   \n",
       "2                       0.00000                     0.000000   \n",
       "3                       0.00000                     0.000000   \n",
       "4                      -8.82132                    13.228012   \n",
       "\n",
       "   aps_CUST_NO_apsdtramt_3_count  aps_CUST_NO_apsdtramt_5_sum  \\\n",
       "0                            0.0                     0.000000   \n",
       "1                            0.0                     0.000000   \n",
       "2                            0.0                     0.000000   \n",
       "3                            0.0                     0.000000   \n",
       "4                           14.0                  -137.656318   \n",
       "\n",
       "   aps_CUST_NO_apsdtramt_5_min  aps_CUST_NO_apsdtramt_5_max  \\\n",
       "0                     0.000000                     0.000000   \n",
       "1                     0.000000                     0.000000   \n",
       "2                     0.000000                     0.000000   \n",
       "3                     0.000000                     0.000000   \n",
       "4                   -31.859766                    33.154947   \n",
       "\n",
       "   aps_CUST_NO_apsdtramt_5_mean  aps_CUST_NO_apsdtramt_5_std  \\\n",
       "0                       0.00000                     0.000000   \n",
       "1                       0.00000                     0.000000   \n",
       "2                       0.00000                     0.000000   \n",
       "3                       0.00000                     0.000000   \n",
       "4                      -8.09743                    16.960602   \n",
       "\n",
       "   aps_CUST_NO_apsdtramt_5_count  aps_CUST_NO_apsdtramt_7_sum  \\\n",
       "0                            0.0                     0.000000   \n",
       "1                            0.0                     0.000000   \n",
       "2                            0.0                     0.000000   \n",
       "3                            0.0                     0.000000   \n",
       "4                           17.0                  -137.656318   \n",
       "\n",
       "   aps_CUST_NO_apsdtramt_7_min  aps_CUST_NO_apsdtramt_7_max  \\\n",
       "0                     0.000000                     0.000000   \n",
       "1                     0.000000                     0.000000   \n",
       "2                     0.000000                     0.000000   \n",
       "3                     0.000000                     0.000000   \n",
       "4                   -31.859766                    33.154947   \n",
       "\n",
       "   aps_CUST_NO_apsdtramt_7_mean  aps_CUST_NO_apsdtramt_7_std  \\\n",
       "0                       0.00000                     0.000000   \n",
       "1                       0.00000                     0.000000   \n",
       "2                       0.00000                     0.000000   \n",
       "3                       0.00000                     0.000000   \n",
       "4                      -8.09743                    16.960602   \n",
       "\n",
       "   aps_CUST_NO_apsdtramt_7_count  aps_CUST_NO_apsdtramt_15_sum  \\\n",
       "0                            0.0                      0.000000   \n",
       "1                            0.0                      0.000000   \n",
       "2                            0.0                     -2.556282   \n",
       "3                            0.0                     -8.257676   \n",
       "4                           17.0                   -174.155486   \n",
       "\n",
       "   aps_CUST_NO_apsdtramt_15_min  aps_CUST_NO_apsdtramt_15_max  \\\n",
       "0                      0.000000                      0.000000   \n",
       "1                      0.000000                      0.000000   \n",
       "2                     -2.556282                      0.000000   \n",
       "3                     -8.257676                     -8.257676   \n",
       "4                    -42.344915                     42.344915   \n",
       "\n",
       "   aps_CUST_NO_apsdtramt_15_mean  aps_CUST_NO_apsdtramt_15_std  \\\n",
       "0                       0.000000                      0.000000   \n",
       "1                       0.000000                      0.000000   \n",
       "2                      -1.278141                      1.807565   \n",
       "3                      -8.257676                      0.000000   \n",
       "4                      -5.122220                     19.844642   \n",
       "\n",
       "   aps_CUST_NO_apsdtramt_15_count  aps_CUST_NO_apsdtramt_30_sum  \\\n",
       "0                             0.0                      0.000000   \n",
       "1                             0.0                      0.000000   \n",
       "2                             2.0                     -2.556282   \n",
       "3                             1.0                     28.234065   \n",
       "4                            34.0                   -328.378033   \n",
       "\n",
       "   aps_CUST_NO_apsdtramt_30_min  aps_CUST_NO_apsdtramt_30_max  \\\n",
       "0                      0.000000                      0.000000   \n",
       "1                      0.000000                      0.000000   \n",
       "2                     -2.556282                      0.000000   \n",
       "3                     -8.257676                     36.491741   \n",
       "4                    -42.344915                     42.344915   \n",
       "\n",
       "   aps_CUST_NO_apsdtramt_30_mean  aps_CUST_NO_apsdtramt_30_std  \\\n",
       "0                       0.000000                      0.000000   \n",
       "1                       0.000000                      0.000000   \n",
       "2                      -1.278141                      1.807565   \n",
       "3                      14.117033                     31.642616   \n",
       "4                      -5.130907                     17.853094   \n",
       "\n",
       "   aps_CUST_NO_apsdtramt_30_count  aps_CUST_NO_apsdtramt_60_sum  \\\n",
       "0                             0.0                      0.000000   \n",
       "1                             0.0                      0.000000   \n",
       "2                             2.0                     -2.556282   \n",
       "3                             2.0                     19.451852   \n",
       "4                            64.0                   -443.849364   \n",
       "\n",
       "   aps_CUST_NO_apsdtramt_60_min  aps_CUST_NO_apsdtramt_60_max  \\\n",
       "0                      0.000000                      0.000000   \n",
       "1                      0.000000                      0.000000   \n",
       "2                     -2.556282                      0.000000   \n",
       "3                    -83.254131                     83.300844   \n",
       "4                    -42.344915                     42.344915   \n",
       "\n",
       "   aps_CUST_NO_apsdtramt_60_mean  aps_CUST_NO_apsdtramt_60_std  \\\n",
       "0                       0.000000                      0.000000   \n",
       "1                       0.000000                      0.000000   \n",
       "2                      -1.278141                      1.807565   \n",
       "3                       3.890370                     61.790761   \n",
       "4                      -4.187258                     18.364779   \n",
       "\n",
       "   aps_CUST_NO_apsdtramt_60_count  \n",
       "0                             0.0  \n",
       "1                             0.0  \n",
       "2                             2.0  \n",
       "3                             5.0  \n",
       "4                           106.0  "
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "pd.set_option('display.max_columns',None)\n",
    "tmp_train.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [],
   "source": [
    "tmp_train.to_csv('../fea/train_tr_aps.csv',index=False)\n",
    "tmp_test.to_csv('../fea/test_tr_aps.csv',index=False)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.18"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
